<template>
  <div>
    <ta-drawer
      :title="editType == '1'? '添加微信':'编辑微信'"
      placement="right"
      :closable="false"
      @close="fnClose"
      :visible="visible"
      width="550"
    >
      <ta-form @submit="handleSubmit" :autoFormCreate="(form)=>{this.form = form}">
        <ta-form-item
          label='公众号名称'
          :labelCol="{ span: 5 }"
          :wrapperCol="{ span: 19 }"
          fieldDecoratorId="name"
          :fieldDecoratorOptions="{rules: [{ required: true, message: '请输入公众号名称!' }]}"
        >
          <ta-input placeholder="请输入公众号名称"/>
        </ta-form-item>
        <ta-form-item
          label='开发者ID'
          :labelCol="{ span: 5 }"
          :wrapperCol="{ span: 19 }"
          fieldDecoratorId="appid"
          :fieldDecoratorOptions="{rules: [{ required: true, message: '请输入开发者ID' }]}"
        >
          <ta-textarea placeholder="请输入开发者ID" :rows="3" :autosize="{ minRows: 3, maxRows: 10 }" />
        </ta-form-item>
        <ta-form-item
          label='开发者秘钥'
          :labelCol="{ span: 5 }"
          :wrapperCol="{ span: 19 }"
          fieldDecoratorId="secret"
          :fieldDecoratorOptions="{rules: [{ required: true, message: '请输入开发者秘钥' }]}"
        >
          <ta-textarea placeholder="请输入开发者秘钥" :rows="3" :autosize="{ minRows: 3, maxRows: 10 }" />
        </ta-form-item>
        <ta-form-item
          label="是否默认"
          :labelCol="{ span: 5 }"
          :wrapperCol="{ span: 19 }"
          fieldDecoratorId="defaultwx"
        >
          <ta-radio-group @change="onChange">
            <ta-radio :value="1" :default-checked="true">是</ta-radio>
            <ta-radio :value="0">否</ta-radio>
          </ta-radio-group>
        </ta-form-item>
        <ta-form-item>
          <div class="button-div">
            <ta-button type='primary' htmlType='submit'>
              保存
            </ta-button>
            <ta-button type='primary' htmlType='button' @click="onResetForm">
              重置
            </ta-button>
          </div>
        </ta-form-item>
      </ta-form>
    </ta-drawer>
  </div>
</template>

<script>
  export default {
    name: "wechatAddEdit",
    props: ['visible', 'editType', 'rowData'],
    data(){
      return {

      }
    },
    methods:{
      fnClose(){
        this.$emit('close')
        this.formData = {}
      },
      onChange(){

      },
      onResetForm(){},
      handleSubmit(){
        this.form.validateFields((err, values) => {
          if (!err) {
            let submitParameter = {
              url: "wechat/saveWechat.do",
              data: values
            };
            Base.submit(this,submitParameter,function () {
              if (this.editType == '1') {
                this.$message.success('新增成功');
              } else {
                  this.$message.success('修改成功');
              }
              this.$emit('fnQuery');
              this.fnClose();
            });
          }
      })
    }
  }
  }
</script>

<style scoped type="text/scss">

</style>
